layui.use('form', function(){
});

var ka=document.getElementById('app');
var status = ka.getAttribute('status');

var clientChart = echarts.init(document.getElementById('countClient'));
var clientOption = {
    tooltip: {
        trigger: 'item',
        formatter: '{a} <br/>{b}: {c} ({d}%)'
    },
    title: {
        text: '近30天客户分析'
    }
    ,series : [
        {
            name: '交易额',
            type: 'pie',
            selectedMode: 'single',
            radius: [0, '30%'],

            label: {
                position: 'inner'
            },
            labelLine: {
                show: false
            },
            data: []
        },
        {
            name: '交易额',
            type: 'pie',
            radius: ['40%', '55%'],
            label: {
                formatter: '{a|{a}}{abg|}\n{hr|}\n  {b|{b}：}{c}  {per|{d}%}  ',
                backgroundColor: '#eee',
                borderColor: '#aaa',
                borderWidth: 1,
                borderRadius: 4,
                rich: {
                    a: {
                        color: '#999',
                        lineHeight: 22,
                        align: 'center'
                    },
                    hr: {
                        borderColor: '#aaa',
                        width: '100%',
                        borderWidth: 0.5,
                        height: 0
                    },
                    b: {
                        fontSize: 16,
                        lineHeight: 33
                    },
                    per: {
                        color: '#eee',
                        backgroundColor: '#334455',
                        padding: [2, 4],
                        borderRadius: 2
                    }
                }
            },
            data:[],
        }
    ]
};

if(status === '0'){
    clientOption.title.text = '近30天销售失败客户分析';
    clientOption.series[0].name = '错失交易额';
    clientOption.series[1].name = '错失交易额';
}

$.ajax({
    type: "post",
    url: "/copOrder/ClientGen/"+status,
    headers: { 'Content-Type': 'application/json;charset=utf-8' },
    dataType: 'json',
    async: false,
    data: {},
    success: function (result) {
        console.log(result)
        if (result.code == 500) {
            layer.msg(result.msg)
        } else {
            clientOption.series[0].data = result.data;
        }
    }
});

$.ajax({
    type: "post",
    url: "/copOrder/ClientBuy/"+status,
    headers: { 'Content-Type': 'application/json;charset=utf-8' },
    dataType: 'json',
    async: false,
    data: {},
    success: function (result) {
        console.log(result)
        if (result.code == 500) {
            layer.msg(result.msg)
        } else {
            clientOption.series[1].data = result.data;
        }
    }
});
clientChart.setOption(clientOption);



